APM.BusinessDetailExperienceAreaController = Ember.Controller.extend({
	needs: ["businessCenter", "businessDetail"],

	business: Ember.computed.alias('controllers.businessDetail.model'),
	
	clickTimePoint: Ember.computed.oneWay('controllers.businessDetail.clickTimePoint'),

	timePointLisenterEvent:Ember.computed("clickTimePoint", function(key, value){
		var view = Broada.getView("businessTimeRangesTopo");
		if(this.get("clickTimePoint") != null){
			var date = new Date(this.get("clickTimePoint"));
			if(typeof view != "undefined"){
				var range = view.getTimeRange().endDate - view.getTimeRange().startDate;				
				this.set("startDate", new Date(date-range));
				this.set("endDate", date);
			}
			typeof view != "undefined"?view.set("btnTxt", date?APM.util.formatDate(date, "f"):null):null;
			this.set("dayTime",APM.util.formatDate(date, "yyyy-MM-dd"));
			this.requirePerformances();
		}
	}),

	dayTime:APM.util.formatDate(new Date(new Date() - timeD_value),"yyyy-MM-dd"),

	businessChange: Ember.observer("business", function(){
		this.requirePerformances();
	}),

	defaultSelect : "system/response_time/avg",

	performances : Ember.A(),

	init: function(){
		this.set("cancelSet",true);
		if(overviewOrCenterSwitch == "business"){
			this.set("defaultSelect","business/response_time/avg");
		}else{
			this.set("defaultSelect","system/response_time/avg");
		}	
	},

	requirePerformances: function(time){
		var ctrl = this;
		var business = this.get("business");
		if(!business)
			return;

		var sortField = this.get("defaultSelect");

		var startDate = this.get("startDate"),
			endDate = this.get("endDate");

		var todySDate = new Date(APM.util.formatDate(startDate,"yyyy-MM-dd"));
		var todyEDate = new Date(APM.util.formatDate(endDate,"yyyy-MM-dd"));
			startDate = new Date(todySDate.setHours(0));
			todyEDate.setHours(23);
			todyEDate.setMinutes(59);
			todyEDate.setSeconds(59);
			endDate = new Date(todyEDate);
		
		var params = {
			appId: business.id,
			sortField: sortField,
			startDate: +startDate,
			endDate: +endDate
		}
		//开发调试模式参数
		if( isLocalDebugModel ){
			delete params.sortField;
			delete params.startDate;
			delete params.endDate;
		}

		return this.store.ajax("GET", "performances/area", params)
		.then(function(response){
			ctrl.set("areaData", Ember.A(response["result"]));
			ctrl.set("mapType", response["mapType"]);
			return response;
		});
	},

	actions : {
		selectOnChange : function(data, view) {
			this.set("defaultSelect", data);
			this.requirePerformances();
		},

		timeRangesChange: function(timeRange){
			this.set("startDate", timeRange.startDate);
			this.set("endDate", timeRange.endDate);
			this.requirePerformances();
		}
	}
});

	